Using Automation Script Libraries

Use automation script libraries to organize code on the server and reuse the code in automation scripts by attaching the automation script library to the desired automation scripts.

NOTE You can attach multiple automation script libraries to automation scripts but you cannot attach automation script libraries to other automation script libraries.

You will be able to easily maintain the code by modifying it once on the server (within the automation script library) and the code updates will be automatically distributed to all the automation scripts calling the automation script library.

The typical use case scenarios in which an automation script library is used:

  1. Executing a specific block of code after an entity business status is changed. To use an automation script library to execute a block of code after a business status is changed, you need to create it first. For information on how to create an automation script library, see Create an Automation Script Library.
  2. Call the automation script library from a server script using server-side functions.

To see the list of defined automation script libraries, from the menu, click Advanced > Server Automation Script Libraries. The Server Automation Script Libraries List page appears:

Particular automation script libraries

The code provided in automation script libraries with a name which follows the following naming convention statusChange_EntityName are executed automatically on entity stage transition. These libraries exist in the context of previous and current execution.

Copy

var currStatusName = getBusinessStatusName("EntityName", context.BusinessStatus);
var previousStatusName = getBusinessStatusName("EntityName ", context.PreviousBusinessStatus);

To view the state transition, you should use after update server scripts using the following commands:

Copy

var ent = getById("EntityName",context.Id);

svar prevBussinessStatusId = context.BeforeValues.businessStatusId;
var bussinessStatusId = ent. businessStatusId;
if (businessStatusId != prevBussinessStatusId) {
        // state transition occurred from prevBussinessStatusId to businessStatusId
}